<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:concept="http://xbrl.org/formula/conformance/example" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
      <reg:assumedOwnership moment="2008-09-01T00:00:00" />
    </reg:owner>
  </owners>

  <number>90213</number>

  <name>xfi:filter-member-network-selection</name>

  <documentation>

    <xhtml:p>
      Dimension tree-view of this testcase: 
    </xhtml:p>

    <xhtml:img src="filter-member-dimension-values.png" border="1"/>

    <xhtml:ul>
      <xhtml:li>
      <xhtml:i>primaryItems</xhtml:i> has the primary item used in dimension filter test instances (Peak), for an instance of mountain peaks each of a dimension of region and peak height, where this Peak primary item contains the mountain's name as its text.  The Peak concept primary item has an <xhtml:i>all</xhtml:i> relationship to the SummitHypercube.
      </xhtml:li>
      <xhtml:li>
      <xhtml:i>hypercubes</xhtml:i> has the SummitHypercube and an explicit dimension, Location, arranged in hierarchy of regions each in separate extended link.
      </xhtml:li>
      <xhtml:li>
      <xhtml:i>regions</xhtml:i> breaks down into continents into countries, each in their own dimension as a DRS.  This allows demonstrating the use of member hierarchies in a DRS with use of targetRole to assemble connected relationships.
      </xhtml:li>
    </xhtml:ul>
  </documentation>

  <reference
    xlink:type="simple"
    xlink:href="90211 xfi.filter-member-network-selection function.xml">
    function definition  
  </reference>

  <variation id="V-01">
    <name>A list of members of North America</name>
    <documentation>
      <xhtml:p>
        Peak(primaryItems)-&gt;SummitHypercube(hypercubes)-&gt;Location-&gt;Regions(regions)-&gt;America(americas)-&gt;NorthAmerica-&gt;(UnitedStates,Mexico,Canada). 
        The test is organized to be insensitive to the order of returned
        member items, though the XPath 2 sequence operators mostly assure
        that it be in document order.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V01" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V01">
        xfi:filter-member-network-selection(
          QName('http://xbrl.org/formula/conformance/example','concept:Location'),
          xs:QName('concept:NorthAmerica'),
          "http://xbrl.org/formula/conformance/example/role/americas",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'descendant'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 3 and
         index-of($result,
             QName('http://xbrl.org/formula/conformance/example','concept:Mexico')) and
         index-of($result,
             xs:QName('concept:Canada')) and
         index-of($result,
             QName('http://xbrl.org/formula/conformance/example','concept:UnitedStates'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-02">
    <name>A list of members of Oceania (2 levels of descendants)</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V02" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V02">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:Oceania'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'descendant'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 5 and
         index-of($result,
             xs:QName('concept:Australasia')) and
         index-of($result,
             xs:QName('concept:Australia')) and
         index-of($result,
             xs:QName('concept:NewZealand')) and
         index-of($result,
             xs:QName('concept:Melanesia')) and
         index-of($result,
             xs:QName('concept:Indonesia'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03">
    <name>A list of Oceania itself and just child subregions</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V03" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V03">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:Oceania'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 3 and
         index-of($result,
             xs:QName('concept:Australasia')) and
         index-of($result,
             xs:QName('concept:Melanesia')) and
         index-of($result,
             xs:QName('concept:Oceania'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04">
    <name>A list of Asia itself and subregions with highest peaks</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V04" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V04">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:Asia'),
          "http://xbrl.org/formula/conformance/example/role/asia",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'descendant-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 3 and
         index-of($result,
             xs:QName('concept:Asia')) and
         index-of($result,
             xs:QName('concept:SouthAsia')) and
         index-of($result,
             xs:QName('concept:Nepal'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04a">
    <name>A empty list of children of child-less member</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V04a" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V04a">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:Nepal'),
          "http://xbrl.org/formula/conformance/example/role/asia",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         empty( $result )
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Error of non-member concept argument as dimension member argument</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V05" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V05">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:Mars'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <!-- removed 2011-03-10
      <error>xfie:unrecognisedExplicitDimensionValueQName</error>
      -->
      <cfcn:test>
         empty( $result )
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-06">
    <name>Error of non-XBRL element argument as dimension member argument</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V06" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V06">
        xfi:filter-member-network-selection(
          xs:QName('concept:Location'),
          xs:QName('concept:nonXbrlElement'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <!-- removed 2011-03-10
      <error>xfie:unrecognisedExplicitDimensionValueQName</error>
      -->
      <cfcn:test>
         empty( $result )
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-07">
    <name>Raises an error for non-xbrl dimension element argument</name>
    <documentation>
      <xhtml:p>
        Tests that error is detected when the concept qname is an element, not an XBRL
        concept.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V07" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V07">
        xfi:filter-member-network-selection(
          xs:QName('concept:nonXbrlElement'), 
          xs:QName('concept:Oceania'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-08">
    <name>Raises an error for an attribute declaration argument</name>
    <documentation>
      <xhtml:p>
        Tests that error is detected when the dimension name argument declares an attribute.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V08" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V08">
        xfi:filter-member-network-selection(
          xs:QName('concept:anAttribute'), 
          xs:QName('concept:Oceania'),
          "http://xbrl.org/formula/conformance/example/role/oceania",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-09">
    <name>Raises an error for an xbrli namespace&apos;ed argument</name>
    <documentation>
      <xhtml:p>
        Tests that error is detected when the dimension qname is xbrli:item
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V09" xlink:type="simple" xlink:href="filter-member-dimension-values.xsd"/>
      <linkbase xlink:type="simple" xlink:href="filter-member-dimension-values-definition.xml"/>
      <cfcn:call file="V09">
        xfi:filter-member-network-selection(
          xs:QName('xbrli:item'), 
          xs:QName('concept:Oceania'),
          "http://xbrl.org/formula/conformance/example/role/foobar",
          "http://xbrl.org/formula/conformance/example/role/foobar",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-10">
    <name>Filter-member network is ambiguous but not referenced
    </name>
    <documentation>
      <xhtml:p>
        Filter-member network has an ambiguity but function call is not referencing link role containing ambiguity in this variation.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V10" xlink:type="simple" xlink:href="ambiguity-test-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="ambiguity-test-concepts-definition.xml"/>
      <cfcn:call file="V10">
        xfi:filter-member-network-selection(
          xs:QName('concept:Dimension'), 
          xs:QName('concept:MemB'),
          "http://xbrl.org/formula/conformance/example/role/dimensions",
          "http://xbrl.org/int/dim/arcrole/domain-member",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 2 and
         index-of($result,
             xs:QName('concept:MemB')) and
         index-of($result,
             xs:QName('concept:MemC'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-11">
    <name>Filter-member network that is referenced is ambiguous
    </name>
    <documentation>
      <xhtml:p>
        Filter-member network has an ambiguity which is referenced by the linkrole and arcrole of the function call.  The ambiguity is introduced because there are two different extended links (of role test-role, one presentationLink, the other definitionLink) that each define the same arcs (of arcrole test-arcrole).  Each link has MemA-&gt;MemB-&gt;MemC.  This ambiguity is no longer an error.  Thus there are two relationships each to memB and to memC, which is the same situation as when a 'normal' network has a domain member appearing as multiple leaf nodes in the same hierarchy.  Because the result is a set, which by definition has only distinct members, the result has only one each of memB and memC reported.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V11" xlink:type="simple" xlink:href="ambiguity-test-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="ambiguity-test-concepts-definition.xml"/>
      <cfcn:call file="V11">
        xfi:filter-member-network-selection(
          xs:QName('concept:Dimension'), 
          xs:QName('concept:MemB'),
          "http://xbrl.org/formula/conformance/example/role/test-role",
          "http://xbrl.org/formula/conformance/example/arcrole/test-arcrole",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
  <!-- removed 2011-03-10
      <error>
          xfie:ambiguousFilterMemberNetwork
      </error>
  -->
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 2 and
         index-of($result,
             xs:QName('concept:MemB')) and
         index-of($result,
             xs:QName('concept:MemC'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-12">
    <name>Filter-member network that is referenced is ambiguous but prohibited by extension linkbase
    </name>
    <documentation>
      <xhtml:p>
        Filter-member network ambiguity arcs are prohibited by an extension linkbase, to verify that ambiguous arcs prohibition works in the formula processor.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="false" xlink:type="simple" xlink:href="ambiguity-test-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="ambiguity-test-concepts-presentation.xml"/>
      <linkbase xlink:type="simple" xlink:href="ambiguity-test-concepts-definition.xml"/>
      <linkbase readMeFirst="true" id="V12" xlink:type="simple" xlink:href="ambiguity-test-prohibiting-arcs-definition.xml"/>
      <cfcn:call file="V12">
        xfi:filter-member-network-selection(
          xs:QName('concept:Dimension'), 
          xs:QName('concept:MemB'),
          "http://xbrl.org/formula/conformance/example/role/test-role",
          "http://xbrl.org/formula/conformance/example/arcrole/test-arcrole",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 2 and
         index-of($result,
             xs:QName('concept:MemB')) and
         index-of($result,
             xs:QName('concept:MemC'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-13">
    <name>Filter-member network can be of any link role and arc role in any linkbase, test presentation linkbase
    </name>
    <documentation>
      <xhtml:p>
        A filter-member network in presentation linkbase, link test-role1, custom arcrole test-arcrole, has hierarchy dim, memA, memB, memC, but in definition linkbase, link test-role2, has hierarchy dim, memC, memB, memA.  This test should retrieve the hierarchy of memB and below (child-or-self), from the presentation linkbase, e.g., getting memB and memC.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true"  id="V13" xlink:type="simple" xlink:href="non-dim-hierarchy-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="non-dim-hierarchy-presentation.xml"/>
      <linkbase xlink:type="simple" xlink:href="non-dim-hierarchy-definition.xml"/>
      <cfcn:call file="V13">
        xfi:filter-member-network-selection(
          xs:QName('concept:Dimension'), 
          xs:QName('concept:MemB'),
          "http://xbrl.org/formula/conformance/example/role/test-role2",
          "http://xbrl.org/formula/conformance/example/arcrole/test-arcrole",
          'child-or-self'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 2 and
         index-of($result,
             xs:QName('concept:MemB')) and
         index-of($result,
             xs:QName('concept:MemC'))
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-14">
    <name>Filter-member network can be of any link role and arc role in any linkbase, test definition linkbase
    </name>
    <documentation>
      <xhtml:p>
        Same as V-13 but this test should retrieve the hierarchy of children below memB (child), from the definition linkbase, e.g., getting only memA.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema readMeFirst="true" id="V14" xlink:type="simple" xlink:href="non-dim-hierarchy-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="non-dim-hierarchy-presentation.xml"/>
      <linkbase xlink:type="simple" xlink:href="non-dim-hierarchy-definition.xml"/>
      <cfcn:call file="V14">
        xfi:filter-member-network-selection(
          xs:QName('concept:Dimension'), 
          xs:QName('concept:MemB'),
          "http://xbrl.org/formula/conformance/example/role/test-role1",
          "http://xbrl.org/formula/conformance/example/arcrole/test-arcrole",
          'child'
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName* and
         count( $result ) eq 1 and
         $result [1] eq
             xs:QName('concept:MemA')
      </cfcn:test>
    </outputs>
  </variation>

  <revisions>
    <reg:revision on="2008-09-01T00:00:00" by="herm">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-09-02T00:00:00" by="herm">
      <xhtml:p>
        Added v-10 to v-12 for error code xbrldfe:ambiguousFilterMemberNetwork.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2009-03-25T00:00:00" by="herm">
      <xhtml:p>
        Updated V-12 and added v-13 to v-14.
      </xhtml:p>
    </reg:revision>

    <reg:revision on="2010-09-09T00:00:00" by="herm">
      <xhtml:p>
        Changed input role URIs to strings for cast-less coding and to be similar to fn:QName's $paramURI, an xs:string.
      </xhtml:p>
    </reg:revision>

    <reg:revision on="2011-01-11T00:00:00" by="herm">
      <xhtml:p>
        Added V-04a, to be sure that a request for children of a child-less member is an empty list.
      </xhtml:p>
    </reg:revision>

    <reg:revision on="2011-02-28T10:00:00" by="herm">
      <xhtml:p>
        Added missing xmlns:xs.  Changed some tests to more compact xs:QName from longer fn:QName
      </xhtml:p>
    </reg:revision>

    <reg:revision on="2011-03-10T23:00:00" by="herm">
      <xhtml:p>
        Removed errors unrecognisedExplicitDimensionValueQName and ambiguousFilterMemberNetwork/
      </xhtml:p>
    </reg:revision>

    <reg:revision on="2011-03-16T11:00:00" by="herm">
      <xhtml:p>
        Updated V-11 description and results to reflect that this test case has multiple relationships to its members, but
        as the result is a set, which by definition has distinct members, the members are reported only once.
      </xhtml:p>
    </reg:revision>

  </revisions>
</testcase>
